package edu.nctu.csie.jichang.dp.creational;

public class SimpleFactory {
	public static void main(String[] args)throws Exception {
		SimpleFactoryFactory.createSimpleClass("A");
		SimpleFactoryFactory.createSimpleClass("B");
	}
}
class SimpleFactoryFactory{
	static String myPackage = "edu.nctu.csie.jichang.dp.creational";
	public static SimpleClass createSimpleClass(String name) throws Exception {
		return (SimpleClass)Class.forName(myPackage+"."+"SimpleClass"+name).newInstance();
	}
}
abstract class SimpleClass{}
class SimpleClassA extends SimpleClass{
	SimpleClassA(){System.out.println("SimpleClassA");}
}
class SimpleClassB extends SimpleClass{
	SimpleClassB(){System.out.println("SimpleClassB");}
}